<template>
  <div>
    <MyHead :title="'填写地址'" :show="true"> </MyHead>
    <div>
      <van-address-edit
       :area-list='areaList'
        value="areaList.data.name"
        show-postal
        show-delete
        show-set-default
        show-search-result
        :area-columns-num="3"
        :search-result="searchResult"
        :tel-maxlength="11"
        :area-columns-placeholder="['请选择', '请选择', '请选择']"
        @save="onSave"
        @delete="onDelete"
        @change-detail="onChangeDetail"
      />
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import { Toast } from 'vant';
import areaList from '../../utils/citylist'
export default {
    
  data() {
    return {
      areaList,
      searchResult: [],
        arrArea:[]
    };
  },
  methods: {
    onSave(v) {
      Toast('save');
      console.log(v);
      axios.post("http://localhost:3000/dizhi",{
        ...v
      })
      .then(res=>{
        console.log(res);
      })
      this.$router.push({name:"addressedit"})
    },
    onDelete() {
      Toast('delete');
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: '黄龙万科中心',
            address: '杭州市西湖区',
          },
        ];
      } else {
        this.searchResult = [];
      }
    },
  },
  mounted(){
     
  }
}
</script>